<template>
  <svg :style="{ width, height }" class="svg-icon">
    <use :xlink:href="symboId" :fill="color" />
  </svg>
</template>

<script lang="ts" setup name="SvgIcon">
  import { computed } from "vue";
  const props = defineProps({
    //xlink:href属性值前缀
    prefix: {
      type: String,
      default: "icon",
    },
    name: {
      type: String,
      required: true,
    },
    color: {
      type: String,
      default: "#333",
    },
    width: {
      type: String,
      default: "16px",
    },
    height: {
      type: String,
      default: "16px",
    },
  });
  const symboId = computed(() => `#${props.prefix}-${props.name}`);
</script>

<style scoped lang="scss">
  .svg-icon {
    position: relative;
    fill: currentColor;
    vertical-align: -2px;
  }
</style>
